require "io"
require "console"
require "screen"
require "controls"

local white = Color.new(255,255,255)
local green = Color.new(0,255,255)
local red = Color.new(255,0,0)
local myImage = Screen.loadImage("/teclado.png")

while true do
  Controls.init()
  local pad = Controls.read()

  if Controls.check(pad,KEY_A) then
    break
  end
  if Controls.check(pad,KEY_B) then
    console.hello()
  end
  if Controls.check(pad,KEY_X) then
    console.puts("oioi")
  end
  if Controls.check(pad,KEY_Y) then
    console.puts("oioi2",4,4)
  end

  Screen.waitVblankStart()
  Screen.refresh()

  Screen.fillRect(0,319,0,239,white,BOTTOM_SCREEN)
  if myImage==nil then
    Screen.fillRect(0,319,0,239,red,BOTTOM_SCREEN)
  else
    Screen.drawImage(0,0,myImage,BOTTOM_SCREEN)
--    Screen.fillRect(0,319,0,239,green,BOTTOM_SCREEN)
  end

  Screen.flip()
end

--System.exit()

